package com.itheima.mycollection;

import java.util.LinkedList;
import java.util.Scanner;

public class Demo5 {
    static LinkedList<String> list = new LinkedList<>();
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        lo:
        while (true) {
            System.out.println("请选择您要进行的操作【0:退出 1:添加 2:取出】");
            int choice = sc.nextInt();
            switch (choice) {
                case 1:
                    addElement();
                    break;
                case 2:
                    for (String s : list) {
                        System.out.println(s);
                    }
                    break;
                case 0:
                    break lo;
                default:
                    System.out.println("您的操作有误");
            }
        }


    }

    private static void addElement() {
        System.out.println("请输入您要添加的元素");
        String element = sc.next();
        list.addFirst(element);

    }


}
